/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sms4j;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import sms4j.config.Config;
import sms4j.listener.SocketMessageListenerThread;
import sms4j.modem.gateway.GsmModemGateway;

/**
 *
 * @author Swang
 */
public class Main {

    private static final Log log = LogFactory.getLog(Main.class);

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        if (args.length > 0) {
            String arg = args[0];
            if (arg.trim().equalsIgnoreCase("start")) {
                log.info("Init Config From sms4j.properties");
                Config.init();
                log.info("Init and Start Gsm Modem Gateway Service");
                GsmModemGateway.init();
                log.info("Start listen socket");
                SocketMessageListenerThread.getInstance().start();
                log.info("Complete start");
            } else if (arg.trim().equalsIgnoreCase("stop")) {
                log.info("Stop Gsm Modem Gateway Service");
                GsmModemGateway.shutdown();
                log.info("Stop listen socket");
                SocketMessageListenerThread.getInstance().closeServiceSocket();
                System.exit(0);
            }
        } else {
            System.out.println("Run failure! Please Append Param Start Or Stop");
        }
    }
}
